home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / dos / changemode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-12  |  2.2 KB  |  90 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: changemode.c,v 1.1 1996/09/11 12:54:45 digulla Exp $
  4.     $Log: changemode.c,v $
  5.     Revision 1.1  1996/09/11 12:54:45  digulla
  6.     A couple of new DOS functions from M. Fleischer
  7.  
  8.     Desc:
  9.     Lang: english
  10. */
  11. #include <clib/exec_protos.h>
  12. #include <dos/dosextens.h>
  13. #include <dos/filesystem.h>
  14. #include "dos_intern.h"
  15.  
  16. /*****************************************************************************
  17.  
  18.     NAME */
  19.     #include <clib/dos_protos.h>
  20.  
  21.     __AROS_LH3(BOOL, ChangeMode,
  22.  
  23. /*  SYNOPSIS */
  24.     __AROS_LHA(ULONG, type,    D1),
  25.     __AROS_LHA(BPTR,  object,  D2),
  26.     __AROS_LHA(ULONG, newmode, D3),
  27.  
  28. /*  LOCATION */
  29.     struct DosLibrary *, DOSBase, 75, Dos)
  30.  
  31. /*  FUNCTION
  32.     Try to change the mode used by a lock or filehandle.
  33.  
  34.     INPUTS
  35.     type    - CHANGE_FH or CHANGE_LOCK.
  36.     object  - Filehandle or lock.
  37.     newmode - New mode.
  38.  
  39.     RESULT
  40.     !=0 if all went well, 0 else. IoErr() gives additional information
  41.     in that case.
  42.  
  43.     NOTES
  44.     Since filehandles and locks are identical under AROS the type
  45.     argument is ignored.
  46.  
  47.     EXAMPLE
  48.  
  49.     BUGS
  50.  
  51.     SEE ALSO
  52.  
  53.     INTERNALS
  54.  
  55.     HISTORY
  56.     29-10-95    digulla automatically created from
  57.                 dos_lib.fd and clib/dos_protos.h
  58.  
  59. *****************************************************************************/
  60. {
  61.     __AROS_FUNC_INIT
  62.     __AROS_BASE_EXT_DECL(struct DosLibrary *,DOSBase)
  63.  
  64.     /* Get pointer to filehandle */
  65.     struct FileHandle *fh=(struct FileHandle *)BADDR(object);
  66.  
  67.     /* Get pointer to process structure */
  68.     struct Process *me=(struct Process *)FindTask(NULL);
  69.  
  70.     /* Get pointer to I/O request. Use stackspace for now. */
  71.     struct IOFileSys io,*iofs=&io;
  72.  
  73.     /* Prepare I/O request. */
  74.     iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
  75.     iofs->IOFS.io_Message.mn_ReplyPort   =&me->pr_MsgPort;
  76.     iofs->IOFS.io_Message.mn_Length      =sizeof(struct IOFileSys);
  77.     iofs->IOFS.io_Device =fh->fh_Device;
  78.     iofs->IOFS.io_Unit   =fh->fh_Unit;
  79.     iofs->IOFS.io_Command=FSA_FILE_MODE;
  80.     iofs->IOFS.io_Flags  =0;
  81.     iofs->io_Args[0]=newmode;
  82.  
  83.     /* Send the request. */
  84.     DoIO(&iofs->IOFS);
  85.     
  86.     /* Set error code and return */
  87.     return (me->pr_Result2=iofs->io_DosError)==0;
  88.     __AROS_FUNC_EXIT
  89. } /* ChangeMode */
  90.